package com.jevons.muffin;

import android.app.Application;
import android.content.Context;

import com.jevons.muffin.crash.CrashExceptionHandler;
import com.jevons.muffin.utilcode.CrashPrintUtils;
import com.jevons.muffin.utilcode.LogUtils;
import com.jevons.muffin.utilcode.Utils;


/**
 * @author linaisheng
 * Created at 2019/1/21.
 */

public class BaseApplication extends Application {

    private static Context context;

    @Override
    public void onCreate() {
        super.onCreate();

        context = getApplicationContext();

        Utils.init(this);

        initCrashHandler();

//        LogUtils.getConfig()
//                .setGlobalTag("iMobile")
//                .setConsoleSwitch(Config.IS_LOG_DEBUG)
//                .setSingleTagSwitch(true)
//                .setLog2FileSwitch(Config.IS_LOG_OUT_TO_FILE);
    }

    /**
     * 初始化崩溃日志收集类
     */
    private void initCrashHandler() {
        //崩溃日志开关没打开的话则不记录崩溃日志
//        if (Config.IS_CRASH_LOG_OUT_TO_FILE) {
            CrashExceptionHandler.getInstance().init(this)
                    .setExceptionListener(new CrashPrintUtils.HandleExceptionListener() {
                        @Override
                        public void handleExceptionSuccess(String fullPath) {
                            LogUtils.e("handleExceptionSuccess:" + fullPath);
                        }
                    });
//        }
    }

    /**
     * 获取context
     *
     * @return
     */
    public static Context getContext() {
        return context;
    }
}
